package com.lintf.starter.api.impl;

import com.lintf.starter.api.UserDTO;
import com.lintf.starter.api.UserService;
import org.apache.dubbo.config.annotation.DubboService;

/**
 * @author lin tingfeng
 * @ system Mac
 * @ data 2025/6/6 15:39
 * @ package_name com.lintf.starter.service
 * @ project_name my-diy-project
 * @ desc
 */
@DubboService(version = "1.0.0")
public class UserServiceImpl implements UserService {
    @Override
    public UserDTO getUserById(Long userId) {
        UserDTO userDTO = new UserDTO();
        userDTO.setUserId(10086L);
        userDTO.setUsername("lin");
        userDTO.setStatus(1);
        return userDTO;
    }

    @Override
    public Boolean updateUserStatus(Long userId, Integer status) {
        // 模拟更新用户状态
        if (userId == null || status == null) {
            System.out.println("更新用户状态失败: userId或status不能为空");
            return false;
        }
        if (userId != 10086L) {
            System.out.println("更新用户状态失败: userId不匹配");
            return false;
        }
        if (status != 0 && status != 1) {
            System.out.println("更新用户状态失败: status必须是0或1");
            return false;
        }
        System.out.println("更新用户状态成功: userId=" + userId + ", status=" + status);
        return true;
    }
}
